//
//  HJHBaseNaviController.swift
//  Weibo
//
//  Created by 黄健桦 on 2016/9/22.
//  Copyright © 2016年 黄健桦. All rights reserved.
//

import UIKit

class HJHBaseNaviController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //重写push方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        print(childViewControllers.count)
        
        let count = childViewControllers.count
        
        if count > 0 {
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(back))
        
            viewController.hidesBottomBarWhenPushed = true
        
        }
        
        super.pushViewController(viewController, animated: animated)
        
        print(childViewControllers.count)
    
    }
    
    @objc private func back() {
        
        self.popViewController(animated: true)
    
    }

}
